﻿using System.Collections.Generic;
using System.Linq;
using WordSmith_V1.Library.Security;

namespace WordSmith_V1.Library.Model
{
    public class Role
    {
        private readonly IList<Right> _localRights;
        protected Role()
        {
            _localRights = new List<Right>();
        }        
        public virtual int Id { get; protected set; }
        public virtual string RoleName { get; protected set; }
        public virtual IList<User> UsersInRole { get; protected set; }
        public virtual bool Protected { get; protected set; }
        

        /// <summary>
        /// Gets the local rights for the role, disregarding plugins
        /// </summary>
        public virtual IEnumerable<Right> LocalRights { get { return _localRights; } }

        public virtual void AddRight(Right right)
        {
            _localRights.Add(right);
        }
        public virtual void RemoveRight(Right right)
        {
            _localRights.Remove(_localRights.FirstOrDefault(r => r.Id == right.Id));
        }

    }
}
